<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html xmlns:th="" lang="zh-CN">
<%@include file="/WEB-INF/pages/base/include.jsp"%>
<body>
<div id="wrapper">
    <%@include file="/WEB-INF/pages/base/menu.jsp"%>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header">用户管理</h3>
            </div>
        </div>
        <div class="row">
            <form class="form-horizontal" data-parsley-validate>
                <div class="col-lg-12 col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">用户编辑</div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12 col-md-12">
                                    <div class="form-group">
                                         <label class="col-lg-2 clo-md-2 control-label">姓名：</label>
                                         <div class="col-lg-8">
                                             <p id="name" ></p>
                                         </div>
                                     </div>
                                     <div class="form-group">
                                         <label class="col-lg-2 clo-md-2 control-label">联系电话：</label>
                                         <div class="col-lg-8">
                                             <p id="phone" ></p>
                                         </div>
                                     </div>
                                     <div class="form-group">
                                         <label class="col-lg-2 clo-md-2 control-label">创建时间：</label>
                                         <div class="col-lg-8">
                                             <p id="createTime" ></p>
                                         </div>
                                     </div>
                                     <div class="form-group">
                                         <label class="col-lg-2 clo-md-2 control-label">身份证号：</label>
                                         <div class="col-lg-8">
                                             <p id="idCard" ></p>
                                         </div>
                                     </div>
                                   	<div class="form-group">
                                        <label class="col-lg-2 clo-md-2 control-label">用户状态：</label>
                                        <div class="col-lg-8">
                                            <select name="" id="typeSelect" class="form-control" style="max-width: 120px">
                                                <option value="0">非认证用户</option>
                                                <option value="10">认证用户</option>
                                                <option value="11">代理商</option>
                                                <option value="2">特殊用户</option>
                                            </select>
                                        </div>
                                    	</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <div class="clearfix"></div>
                    <a class="btn btn-primary" href="javascript:void(0);"
                       style="margin-left:15px;margin-bottom:30px;" onclick="modify()">完成</a>
                    <a class="btn btn-default" href="${webPath}toUser"
                       style="margin-left:15px;margin-bottom:30px;">取消</a>
                    </div>
            </form>
        </div>
    </div>
</div>
<script>	
   	$(function(){
		var accountUuid = "${accountUuid}";
  		var baseURL = "${webPath}/account/detail";
      	var json_package = {
           "head": {},
           "body": {
           	"accountUuid": accountUuid
           }
       	}
   		$.post(baseURL, {"json_package": JSON.stringify(json_package)}, function (result) {
          if (typeof result == 'string') result = JSON.parse(result);
          if (result.body.result == '1') {
              alert(result.body.description)
          } else {
          	var account = result.body.account;
          	$("#name").text(account.name);
          	$("#phone").text(account.phone);
          	$("#createTime").text(account.createTime);
          	$("#idCard").text(account.idCard);
          	var alloptions = $("#typeSelect option");
          	for(var i=0;i<alloptions.length;i++){
          		if($(alloptions[i]).val()==account.typeKey){
          			$(alloptions[i]).attr('selected', true);
          		}
          	}
          }
      	})
   	});
   	
   	function modify() {
   		var accountUuid = "${accountUuid}";
   		var type=$("#typeSelect option:selected").val();  //获取选中的项
  		var baseURL = "${webPath}/account/modify";
      	var json_package = {
           "head": {},
           "body": {
           	"accountUuid": accountUuid,
           	"type": type
           }
       	}
   		$.post(baseURL, {"json_package": JSON.stringify(json_package)}, function (result) {
          if (typeof result == 'string') result = JSON.parse(result);
          if (result.body.result == '1') {
              alert(result.body.description)
          } else {
        	  alert(result.body.description)
        	  location.href = "${webPath}toUser";
          }
      	})
	}
</script>
</body>
</html>
